<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>不能做到广告在中间的div内居中</title>
		<style type="text/css">
			#maincontent{
				height: 1000px;
				width: 900px;
				border: 2px solid red;
				overflow: auto;
				
			}
			#maincontent #adv{
				position: fixed;
				right: 10px;
				top: calc(45%);
				z-index: 999;
			}
		</style>
	</head>
	<body>
		<div id="head" style="height: 200px; background-color: blue;"></div>
		<div id="maincontent">
			<img src="../img/dog.jpg" height="7000px" width="8000px" />
			<div id="adv">
				<img src="../img/dog2.jpg" height="100px" width="100px" />
			</div>
		</div>
		<div id="footer"></div>
	</body>
</html>
